using UnityEngine;

namespace CinemaDirector
{
	public class ActorState
	{
		public bool isActive;

		public Vector3 position;

		public Quaternion rotation;

		public Vector3 scale;

		public float alpha;

		public string text;

		public bool isStateStored;

		public void StoreState(GameObject actor)
		{
			isStateStored = true;
			isActive = actor.activeSelf;
			Transform transform = actor.transform;
			position = transform.position;
			rotation = transform.rotation;
			scale = transform.localScale;
			StoreWidget(actor.GetComponent<UIWidget>());
		}

		private void StoreWidget(UIWidget widget)
		{
			if (!(widget == null))
			{
				alpha = widget.alpha;
				UILabel uILabel = widget as UILabel;
				if (uILabel != null)
				{
					text = uILabel.text;
				}
			}
		}

		public void RestoreStateTo(GameObject actor)
		{
			if (isStateStored)
			{
				actor.SetActive(isActive);
				Transform transform = actor.transform;
				transform.position = position;
				transform.rotation = rotation;
				transform.localScale = scale;
				RestoreWidget(actor.GetComponent<UIWidget>());
			}
		}

		private void RestoreWidget(UIWidget widget)
		{
			if (!(widget == null))
			{
				widget.alpha = alpha;
				UILabel uILabel = widget as UILabel;
				if (uILabel != null)
				{
					uILabel.text = text;
				}
			}
		}
	}
}
